package com.xuelongjiang.mqdemo.mq;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;

/**
 * @author xuelongjiang
 */
@Service
public class RabbitClient {

    @Autowired
    private RabbitTemplate rabbitTemplate;



    @PostConstruct
    public void init(){

        rabbitTemplate.setConfirmCallback(new RabbitConfirmCallback());

    }


    public  void sendMesgToQuence(String queue, String mes){

        rabbitTemplate.convertAndSend(queue, mes);
    }

    public  void sendToTopic(String exchange, String routingKey, Object object){

        rabbitTemplate.convertAndSend(exchange, routingKey, object);
    }



}
